//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
	components: {//动态扩充组件或组件路径
		//表单header、content、footer对应位置扩充的组件
		gridHeader:'',//{ template: "<div>扩展组xx件</div>" },
		gridBody: '',
		gridFooter: '',
		//弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
		modelHeader: '',
		modelBody: '',
		modelFooter: ''
	},
	buttons: {view: [], box:[],  detail:[]},//扩展的按钮
	methods: {//事件扩展
		getFormOption(field) {
      let option;
      this.editFormOptions.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        });
      });
      return option;
    },
		onInit() {
			const weeks = this.getFormOption('weeks')
			weeks.data = [{value:'星期一',key:1},{value:'星期二',key:2},{value:'星期三',key:3},{value:'星期四',key:4},{value:'星期五',key:5},{value:'星期六',key:6},{value:'星期日',key:7}]
		},
		modelOpenAfter(row){
			//弹窗打开之后
			if(this.currentAction == "Add"){
				this.editFormFields.isTest = 0
			}else{
				this.editFormFields.isTest = row.isTest
				this.editFormFields.time = [row.startTime,row.endTime]
			}
		},
		addBefore(formData) {
      //新建保存前formData为对象，包括明细表
      console.log("%c 🇸🇸: addBefore -> this.editFormFields.time ", "font-size:16px;background-color:#051ebb;color:white;", this.editFormFields)
			formData.mainData.entryType = 2
			if(this.editFormFields.time.length){
				formData.mainData.startTime = this.editFormFields.time[0]
			  formData.mainData.endTime = this.editFormFields.time[1]
			}else{
				formData.mainData.startTime = ''
				formData.mainData.endTime = ''
			}
			
      console.log("%c 🇸🇲: addBefore -> formData ", "font-size:16px;background-color:#caa3cf;color:white;", formData)
			return formData
    },
		updateBefore(formData){
			//编辑保存前formData为对象，包括明细表
			console.log("%c 🇸🇸: addBefore -> this.editFormFields.time ", "font-size:16px;background-color:#051ebb;color:white;", this.editFormFields)
			formData.mainData.entryType = 2
			if(this.editFormFields.time.length){
				formData.mainData.startTime = this.editFormFields.time[0]
			  formData.mainData.endTime = this.editFormFields.time[1]
			}else{
				formData.mainData.startTime = ''
				formData.mainData.endTime = ''
			}
			return formData
		}
	}
};
export default extension;